unit uProjectBiiblioteca;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus, ComCtrls, StdCtrls, DBCtrls,
  Mask, DB, DBTables, Grids, DBGrids;

type
  TfrmPrin = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet4: TTabSheet;
    Memo1: TMemo;
    PageControl2: TPageControl;
    TabSheet5: TTabSheet;
    TabSheet6: TTabSheet;
    TabSheet7: TTabSheet;
    Label1: TLabel;
    Label11: TLabel;
    Label16: TLabel;
    Label19: TLabel;
    Label20: TLabel;
    Label21: TLabel;
    Label22: TLabel;
    Label23: TLabel;
    Label24: TLabel;
    Label25: TLabel;
    Label26: TLabel;
    Label27: TLabel;
    Label28: TLabel;
    Button5: TButton;
    Button6: TButton;
    Button7: TButton;
    Button8: TButton;
    Button9: TButton;
    Button10: TButton;
    Button11: TButton;
    Button12: TButton;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    Label17: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    TabSheet2: TTabSheet;
    TabSheet3: TTabSheet;
    TabSheet8: TTabSheet;
    Label18: TLabel;
    Label29: TLabel;
    Label30: TLabel;
    Label31: TLabel;
    Label32: TLabel;
    Button13: TButton;
    Button14: TButton;
    Button15: TButton;
    Button16: TButton;
    Button18: TButton;
    Button19: TButton;
    Button20: TButton;
    Button21: TButton;
    Label33: TLabel;
    Label34: TLabel;
    Label35: TLabel;
    Label36: TLabel;
    UpdateSQL1: TUpdateSQL;
    DataSource1: TDataSource;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Edit7: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    Edit10: TEdit;
    Edit12: TEdit;
    Edit13: TEdit;
    Edit14: TEdit;
    Edit15: TEdit;
    Edit18: TEdit;
    Edit19: TEdit;
    Edit20: TEdit;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    Edit16: TEdit;
    Edit23: TEdit;
    Edit24: TEdit;
    Edit26: TEdit;
    Edit28: TEdit;
    Edit25: TEdit;
    Edit29: TEdit;
    Edit30: TEdit;
    Edit32: TEdit;
    Edit33: TEdit;
    MaskEdit1: TMaskEdit;
    MaskEdit2: TMaskEdit;
    MaskEdit3: TMaskEdit;
    MaskEdit4: TMaskEdit;
    MaskEdit5: TMaskEdit;
    Query1: TQuery;
    DBGrid1: TDBGrid;
    CBEDITORA: TDataSource;
    editora: TTable;
    CBPERI: TDataSource;
    tbper: TTable;
    DBLookupComboBox1: TDBLookupComboBox;
    Label37: TLabel;
    Edit11: TEdit;
    procedure LimparCampos();
    procedure Button18Click(Sender: TObject);
    procedure Button20Click(Sender: TObject);
    procedure Button21Click(Sender: TObject);
    procedure Button13Click(Sender: TObject);
    procedure TabSheet8MouseActivate(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y, HitTest: Integer;
      var MouseActivate: TMouseActivate);
    procedure TabSheet7ContextPopup(Sender: TObject; MousePos: TPoint;
      var Handled: Boolean);
    procedure TabSheet7MouseActivate(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y, HitTest: Integer;
      var MouseActivate: TMouseActivate);
    procedure TabSheet6MouseActivate(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y, HitTest: Integer;
      var MouseActivate: TMouseActivate);
    procedure TabSheet5MouseActivate(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y, HitTest: Integer;
      var MouseActivate: TMouseActivate);
    procedure Button15Click(Sender: TObject);
    procedure Button19Click(Sender: TObject);
    procedure TabSheet8ContextPopup(Sender: TObject; MousePos: TPoint;
      var Handled: Boolean);
    procedure Button14Click(Sender: TObject);
    procedure TabSheet3MouseActivate(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y, HitTest: Integer;
      var MouseActivate: TMouseActivate);
    procedure Button16Click(Sender: TObject);
    procedure Button8Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure DBComboBox1Change(Sender: TObject);
    procedure ComboBox3Change(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
      var
      var


  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmPrin: TfrmPrin;
  dml: String;

implementation

{$R *.dfm}

procedure TfrmPrin.Button13Click(Sender: TObject);
begin
  dml := 'insert into tb_autor (ID_AUT,SOB_NOME_AUT,NOME_AUT) values (' + Edit25.Text + ',''' + Edit29.Text + ''',''' + Edit30.Text + ''')';

  with Query1 do

  begin
    Active := False;
    SQL.Clear;
    SQL.Append(dml);
    ExecSQL;
    SQL.Clear;
    SQL.Append('select ID_AUT,SOB_NOME_AUT,NOME_AUT from tb_autor');
    Active := True
  end;
end;

procedure TfrmPrin.Button14Click(Sender: TObject);
begin
  dml := 'update tb_autor set SOB_NOME_AUT,NOME_AUT = ''' + Edit29.Text + ''',''' + Edit30.Text + ''' where id_aut = ' + Edit25.Text;
end;

procedure TfrmPrin.Button15Click(Sender: TObject);
begin
  dml := 'delete from tb_autor where ID_AUT = ' + Edit25.Text ;

  with Query1 do

  begin
    Active := False;
    SQL.Clear;
    SQL.Append(dml);
    ExecSQL;
    SQL.Clear;
    SQL.Append('select ID_AUT,SOB_NOME_AUT,NOME_AUT from tb_autor');
    Active := True
  end;
end;

procedure TfrmPrin.Button16Click(Sender: TObject);
begin
  LimparCampos;
end;

procedure TfrmPrin.Button18Click(Sender: TObject);
begin
  dml := 'insert into tb_editora (NOME_EDIT) values (''' + Edit33.Text + ''')';

   with Query1 do

  begin
    Active := False;
    SQL.Clear;
    SQL.Append(dml);
    ExecSQL;
    SQL.Clear;
    SQL.Append('select ID_EDIT,NOME_EDIT from tb_editora');
    Active := True
  end;
end;

procedure TfrmPrin.Button19Click(Sender: TObject);
begin
   dml := 'update tb_editora set NOME_EDIT =  ''' + Edit33.Text + ''' where id_edit = ' + Edit32.Text ;

  with Query1 do

  begin
    Active := False;
    SQL.Clear;
    SQL.Append(dml);
    ExecSQL;
    SQL.Clear;
    SQL.Append('select ID_EDIT,NOME_EDIT from tb_editora');
    Active := True
  end;

end;

procedure TfrmPrin.Button20Click(Sender: TObject);
begin
  dml := 'delete from tb_editora where ID_EDIT = ' + Edit32.Text ;

  with Query1 do

  begin
    Active := False;
    SQL.Clear;
    SQL.Append(dml);
    ExecSQL;
    SQL.Clear;
    SQL.Append('select ID_EDIT,NOME_EDIT from tb_editora');
    Active := True
  end;

end;

procedure TfrmPrin.Button21Click(Sender: TObject);
begin
  LimparCampos;
end;

procedure TfrmPrin.Button5Click(Sender: TObject);
var
cb: Char;
begin
  dml := 'insert into tb_periodico (TITULO_PER,EDITORA_PER,VOL_PER,DATA_LANC_PER,PERIODIC_PER,NUM_ED_PER)  values (''' + Edit24.Text + ''',''' + DBLookupComboBox1.Text + ''','''  + Edit26.Text +  ''',''' + MaskEdit5.Text + ''',''' + Edit28.Text + ''',''' + Edit11.Text + ''')';

  with Query1 do

  begin
    Active := False;
    SQL.Clear;
    SQL.Append(dml);
    ExecSQL;
    SQL.Clear;
    SQL.Append('select * from tb_periodico');
    Active := True
  end;

end;

procedure TfrmPrin.Button6Click(Sender: TObject);
begin
  dml := ' update tb_periodico set TITULO_PER,EDITORA_PER,VOL_PER,DATA_LANC_PER,PERIODIC_PER,NUM_ED_PER = ''' + Edit24.Text + ''',''' + DBLookupComboBox1.Text + ''','''  + Edit26.Text +  ''',''' + MaskEdit5.Text + ''',''' + Edit28.Text + ''',''' + Edit11.Text + ''' where id_per = ' + Edit23.Text;

    with Query1 do

  begin
    Active := False;
    SQL.Clear;
    SQL.Append(dml);
    ExecSQL;
    SQL.Clear;
    SQL.Append('select * from tb_periodico');
    Active := True
  end;

end;

procedure TfrmPrin.Button7Click(Sender: TObject);
begin
  dml := 'delete from tb_periodico where ID_PER = ' + Edit23.Text;

    with Query1 do

  begin
    Active := False;
    SQL.Clear;
    SQL.Append(dml);
    ExecSQL;
    SQL.Clear;
    SQL.Append('select * from tb_periodico');
    Active := True
  end;

end;

procedure TfrmPrin.Button8Click(Sender: TObject);
begin
  LimparCampos;
end;

procedure TfrmPrin.ComboBox3Change(Sender: TObject);
var
sql: String;

begin
//  sql := ;

  //ComboBox3.Items.Add(sql);
end;

procedure TfrmPrin.DBComboBox1Change(Sender: TObject);
begin
  //DBCombo := Query1.ExecSQL;
end;

procedure TfrmPrin.LimparCampos;
begin
  Edit1.Clear;
  Edit2.Clear;
  Edit3.Clear;
  Edit4.Clear;
  Edit5.Clear;
  Edit6.Clear;
  Edit7.Clear;
  Edit8.Clear;
  Edit9.Clear;
  Edit10.Clear;
  MaskEdit1.Clear;
  Edit12.Clear;
  Edit13.Clear;
  Edit14.Clear;
  Edit15.Clear;
  Edit16.Clear;
  MaskEdit2.Clear;
  Edit18.Clear;
  Edit19.Clear;
  Edit20.Clear;
  MaskEdit4.Clear;
  Edit23.Clear;
  Edit24.Clear;
  Edit25.Clear;
  Edit26.Clear;
  Edit28.Clear;
  Edit29.Clear;
  Edit30.Clear;
  Edit32.Clear;
  Edit33.Clear;

end;


procedure TfrmPrin.TabSheet3MouseActivate(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y, HitTest: Integer;
  var MouseActivate: TMouseActivate);
begin
with Query1 do

  begin
    Active := False;
    SQL.Clear;
    SQL.Append('select * from tb_autor');
    Active := True
  end;
end;

procedure TfrmPrin.TabSheet5MouseActivate(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y, HitTest: Integer;
  var MouseActivate: TMouseActivate);
begin
with Query1 do

  begin
    Active := False;
    SQL.Clear;
    SQL.Append('select * from tb_livro');
    Active := True
  end;
end;

procedure TfrmPrin.TabSheet6MouseActivate(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y, HitTest: Integer;
  var MouseActivate: TMouseActivate);
begin
with Query1 do

  begin
    Active := False;
    SQL.Clear;
    SQL.Append('select * from tb_midia');
    Active := True
  end;
end;

procedure TfrmPrin.TabSheet7ContextPopup(Sender: TObject; MousePos: TPoint;
  var Handled: Boolean);
begin
 with Query1 do

  begin
    Active := False;
    SQL.Clear;
    SQL.Append('select * from tb_periodico');
    Active := True
  end;
end;

procedure TfrmPrin.TabSheet7MouseActivate(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y, HitTest: Integer;
  var MouseActivate: TMouseActivate);
begin
with Query1 do

  begin
    Active := False;
    SQL.Clear;
    SQL.Append('select * from tb_periodico');
    Active := True
  end;
end;

procedure TfrmPrin.TabSheet8ContextPopup(Sender: TObject; MousePos: TPoint;
  var Handled: Boolean);
begin
  with Query1 do

  begin
    Active := False;
    SQL.Clear;
    SQL.Append('select ID_EDIT,NOME_EDIT from tb_editora');
    Active := True
  end;
end;

procedure TfrmPrin.TabSheet8MouseActivate(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y, HitTest: Integer;
  var MouseActivate: TMouseActivate);
begin
     with Query1 do

  begin
    Active := False;
    SQL.Clear;
    SQL.Append('select * from tb_editora');
    Active := True
  end;
end;

end.
